﻿
using System;
using System.Collections.Generic;
using System.IO;
using System.Net;
using System.Runtime.InteropServices;
using ExcelDna.Integration;
using ExcelDna.IntelliSense;
using ExcelDna.Integration.Rtd;
using Newtonsoft.Json.Linq;
public static class Performance
{
    public static string baseurl = @"http://172.18.6.2:8000";
    //==========区间回报===========================
    //# 日收益率
    [ExcelFunction(Description = "日收益率")]
    public static object RETU_DAY(
                [ExcelArgument("fnd_cde")] string fnd_cde,
                [ExcelArgument("end_date")] string end_date
                )
    {
        string parstr = baseurl + @"/performance/return_rate_day/?" +
            @"fnd_cde=" + fnd_cde +
            @"&end_date=" + end_date;
        return ExcelAsyncUtil.Run("RETU_DAY",
            new object[] { parstr },
            () => GetSinglval(parstr));
    }
    //  # 周收益率
    [ExcelFunction("周收益率")]
    public static object RETU_WEK(
                [ExcelArgument("fnd_cde")] string fnd_cde,
                [ExcelArgument("end_date")] string end_date
                )
    {
        string parstr = baseurl + @"/performance/return_rate_week/?" +
            @"fnd_cde=" + fnd_cde +
            @"&end_date=" + end_date;
        return ExcelAsyncUtil.Run("RETU_WEK",
            new object[] { parstr },
            () => GetSinglval(parstr));
    }
    //  # 月收益率
    [ExcelFunction("月收益率")]
    public static object RETU_M(
                [ExcelArgument("fnd_cde")] string fnd_cde,
                [ExcelArgument("end_date")] string end_date
                )
    {
        string parstr = baseurl + @"/performance/return_rate_mth/?" +
            @"fnd_cde=" + fnd_cde +
            @"&end_date=" + end_date;
        return ExcelAsyncUtil.Run("RETU_M",
            new object[] { parstr },
            () => GetSinglval(parstr));
    }
    //  # 本月以来收益率
    [ExcelFunction("本月以来收益率")]
    public static object RETU_M0S(
                [ExcelArgument("fnd_cde")] string fnd_cde,
                [ExcelArgument("end_date")] string end_date
                )
    {
        string parstr = baseurl + @"/performance/return_sinc_mth0/?" +
            @"fnd_cde=" + fnd_cde +
            @"&end_date=" + end_date;
        return ExcelAsyncUtil.Run("RETU_M0S",
            new object[] { parstr },
            () => GetSinglval(parstr));
    }




    //  # 近1月以来收益率
    [ExcelFunction("近1月以来收益率")]
    public static object RETU_M1S(
                [ExcelArgument("fnd_cde")] string fnd_cde,
                [ExcelArgument("end_date")] string end_date
                )
    {
        string parstr = baseurl + @"/performance/return_sinc_mth1/?" +
            @"fnd_cde=" + fnd_cde +
            @"&end_date=" + end_date;
        return ExcelAsyncUtil.Run("RETU_M1S",
            new object[] { parstr },
            () => GetSinglval(parstr));
    }
    //  # 近3月以来收益率
    [ExcelFunction("近3月以来收益率")]
    public static object RETU_M3S(
                [ExcelArgument("fnd_cde")] string fnd_cde,
                [ExcelArgument("end_date")] string end_date
                )
    {
        string parstr = baseurl + @"/performance/return_sinc_mth3/?" +
            @"fnd_cde=" + fnd_cde +
            @"&end_date=" + end_date;
        return ExcelAsyncUtil.Run("RETU_M3S",
            new object[] { parstr },
            () => GetSinglval(parstr));
    }
    //  # 本年年以来收益率
    [ExcelFunction("本年年以来收益率")]
    public static object RETU_Y0S(
                [ExcelArgument("fnd_cde")] string fnd_cde,
                [ExcelArgument("end_date")] string end_date
                )
    {
        string parstr = baseurl + @"/performance/return_sinc_year0/?" +
            @"fnd_cde=" + fnd_cde +
            @"&end_date=" + end_date;
        return ExcelAsyncUtil.Run("RETU_Y0S",
            new object[] { parstr },
            () => GetSinglval(parstr));
    }
    //  # 近1年以来收益率
    [ExcelFunction("近1年以来收益率")]
    public static object RETU_Y1S(
                [ExcelArgument("fnd_cde")] string fnd_cde,
                [ExcelArgument("end_date")] string end_date
                )
    {
        string parstr = baseurl + @"/performance/return_sinc_year1/?" +
            @"fnd_cde=" + fnd_cde +
            @"&end_date=" + end_date;
        return ExcelAsyncUtil.Run("RETU_Y1S",
            new object[] { parstr },
            () => GetSinglval(parstr));
    }
    //  # 近2年以来收益率
    [ExcelFunction("近2年以来收益率")]
    public static object RETU_Y2S(
                [ExcelArgument("fnd_cde")] string fnd_cde,
                [ExcelArgument("end_date")] string end_date
                )
    {
        string parstr = baseurl + @"/performance/return_sinc_year2/?" +
            @"fnd_cde=" + fnd_cde +
            @"&end_date=" + end_date;
        return ExcelAsyncUtil.Run("RETU_Y2S",
            new object[] { parstr },
            () => GetSinglval(parstr));
    }
    //  # 近3年以来收益率
    [ExcelFunction("近3年以来收益率")]
    public static object RETU_Y3S(
                [ExcelArgument("fnd_cde")] string fnd_cde,
                [ExcelArgument("end_date")] string end_date
                )
    {
        string parstr = baseurl + @"/performance/return_sinc_year3/?" +
            @"fnd_cde=" + fnd_cde +
            @"&end_date=" + end_date;
        return ExcelAsyncUtil.Run("RETU_Y3S",
            new object[] { parstr },
            () => GetSinglval(parstr));
    }





    //  # 同类基金周收益率平均收益率
    [ExcelFunction("同类基金周收益率平均收益率")]
    public static object RETU_WEK_AVG(
                [ExcelArgument("class_code")] string class_code,
                [ExcelArgument("end_date")] string end_date
                )
    {
        string parstr = baseurl + @"/performance/return_rate_week_avg/?" +
            @"class_code=" + class_code +
            @"&end_date=" + end_date;
        return ExcelAsyncUtil.Run("RETU_WEK_AVG",
            new object[] { parstr },
            () => GetSinglval(parstr));
    }
    //  # 同类基金月收益率平均收益率
    [ExcelFunction("同类基金月收益率平均收益率")]
    public static object RETU_M_AVG(
                [ExcelArgument("class_code")] string class_code,
                [ExcelArgument("end_date")] string end_date
                )
    {
        string parstr = baseurl + @"/performance/return_rate_mth_avg/?" +
            @"class_code=" + class_code +
            @"&end_date=" + end_date;
        return ExcelAsyncUtil.Run("RETU_M_AVG",
            new object[] { parstr },
            () => GetSinglval(parstr));
    }


    //  # 本月以來同类基金区间平均收益率
    [ExcelFunction("本月以來同类基金区间平均收益率")]
    public static object RETU_M0S_AVG(
                [ExcelArgument("class_code")] string class_code,
                [ExcelArgument("end_date")] string end_date
                )
    {
        string parstr = baseurl + @"/performance/return_sinc_mth0_avg/?" +
            @"class_code=" + class_code +
            @"&end_date=" + end_date;
        return ExcelAsyncUtil.Run("RETU_M0S_AVG",
            new object[] { parstr },
            () => GetSinglval(parstr));
    }

    //  # 同类基金近1月以来收益率 平均
    [ExcelFunction("同类基金近1月以来收益率 平均")]
    public static object RETU_M1S_AVG(
                [ExcelArgument("class_code")] string class_code,
                [ExcelArgument("end_date")] string end_date
                )
    {
        string parstr = baseurl + @"/performance/return_sinc_mth1_avg/?" +
            @"class_code=" + class_code +
            @"&end_date=" + end_date;
        return ExcelAsyncUtil.Run("RETU_M1S_AVG",
            new object[] { parstr },
            () => GetSinglval(parstr));
    }
    //  # 同类基金近3月以来收益率 平均
    [ExcelFunction("同类基金近3月以来收益率 平均")]
    public static object RETU_M3S_AVG(
                [ExcelArgument("class_code")] string class_code,
                [ExcelArgument("end_date")] string end_date
                )
    {
        string parstr = baseurl + @"/performance/return_sinc_mth3_avg/?" +
            @"class_code=" + class_code +
            @"&end_date=" + end_date;
        return ExcelAsyncUtil.Run("RETU_M3S_AVG",
            new object[] { parstr },
            () => GetSinglval(parstr));
    }
    //  # 同类基金本年年以来收益率 平均
    [ExcelFunction("同类基金本年年以来收益率 平均")]
    public static object RETU_Y0S_AVG(
                [ExcelArgument("class_code")] string class_code,
                [ExcelArgument("end_date")] string end_date
                )
    {
        string parstr = baseurl + @"/performance/return_sinc_year0_avg/?" +
            @"class_code=" + class_code +
            @"&end_date=" + end_date;
        return ExcelAsyncUtil.Run("RETU_Y0S_AVG",
            new object[] { parstr },
            () => GetSinglval(parstr));
    }
    //  # 同类基金近1年以来收益率 平均
    [ExcelFunction("同类基金近1年以来收益率 平均")]
    public static object RETU_Y1S_AVG(
                [ExcelArgument("class_code")] string class_code,
                [ExcelArgument("end_date")] string end_date
                )
    {
        string parstr = baseurl + @"/performance/return_sinc_year1_avg/?" +
            @"class_code=" + class_code +
            @"&end_date=" + end_date;
        return ExcelAsyncUtil.Run("RETU_Y1S_AVG",
            new object[] { parstr },
            () => GetSinglval(parstr));
    }
    //  # 同类基金近2年以来收益率 平均
    [ExcelFunction("同类基金近2年以来收益率 平均")]
    public static object RETU_Y2S_AVG(
                [ExcelArgument("class_code")] string class_code,
                [ExcelArgument("end_date")] string end_date
                )
    {
        string parstr = baseurl + @"/performance/return_sinc_year2_avg/?" +
            @"class_code=" + class_code +
            @"&end_date=" + end_date;
        return ExcelAsyncUtil.Run("RETU_Y2S_AVG",
            new object[] { parstr },
            () => GetSinglval(parstr));
    }
    //  # 同类基金近3年以来收益率 平均
    [ExcelFunction("同类基金近3年以来收益率 平均")]
    public static object RETU_Y3S_AVG(
                [ExcelArgument("class_code")] string class_code,
                [ExcelArgument("end_date")] string end_date
                )
    {
        string parstr = baseurl + @"/performance/return_sinc_year3_avg/?" +
            @"class_code=" + class_code +
            @"&end_date=" + end_date;
        return ExcelAsyncUtil.Run("RETU_Y3S_AVG",
            new object[] { parstr },
            () => GetSinglval(parstr));
    }






























    //  # 区间收益率实时查询
    [ExcelFunction("区间收益率实时查询")]
    public static object RETU_INTERVAL_REALTIME(
                [ExcelArgument("fnd_cde")] string fnd_cde,
                [ExcelArgument("start_date")] string start_date,
                [ExcelArgument("end_date")] string end_date
                )
    {
        string parstr = baseurl + @"/performance/return_interval_realtime/?" +
            @"fnd_cde=" + fnd_cde +
            @"&start_date=" + start_date +
            @"&end_date=" + end_date;
        return ExcelAsyncUtil.Run("RETU_INTERVAL_REALTIME",
            new object[] { parstr },
            () => GetSinglval(parstr));
    }

    //  # 近3年以来收益率


    // =========================排名信息


    //  # 同类基金区间平均收益率
    [ExcelFunction("同类基金区间平均收益率")]
    public static object RANK_AVG(
                [ExcelArgument("class_code")] string class_code,
                [ExcelArgument("start_date")] string start_date,
                [ExcelArgument("end_date")] string end_date
                )
    {
        string parstr = baseurl + @"/performance/fund_interval_rate/?" +
            @"class_code=" + class_code +
            @"&start_date=" + start_date +
            @"&end_date=" + end_date;
        return ExcelAsyncUtil.Run("RANK_AVG",
            new object[] { parstr },
            () => GetSinglval(parstr));
    }


    //  # 同类基金区间收益排名
    [ExcelFunction("同类基金区间收益排名")]
    public static object RANK_FUND_INTERVAL(
                [ExcelArgument("fnd_cde")] string fnd_cde,
                [ExcelArgument("class_code")] string class_code,
                [ExcelArgument("start_date")] string start_date,
                [ExcelArgument("end_date")] string end_date
                )
    {
        string parstr = baseurl + @"/performance/fund_interval_rank/?" +
            @"fnd_cde=" + fnd_cde +
            @"&class_code=" + class_code +
            @"&start_date=" + start_date +
            @"&end_date=" + end_date;
        return ExcelAsyncUtil.Run("RANK_FUND_INTERVAL",
            new object[] { parstr },
            () => GetSinglval(parstr));
    }


    //  # 同类基金上月排名
    [ExcelFunction("同类基金上月排名")]
    public static object RANK_FUND_LAST_MONTH(
                [ExcelArgument("fnd_cde")] string fnd_cde,
                [ExcelArgument("class_code")] string class_code,
                [ExcelArgument("end_date")] string end_date
                )
    {
        string parstr = baseurl + @"/performance/fund_sinc_last_month_rank/?" +
            @"fnd_cde=" + fnd_cde +
            @"&class_code=" + class_code +
            @"&end_date=" + end_date;
        return ExcelAsyncUtil.Run("RANK_FUND_LAST_MONTH",
            new object[] { parstr },
            () => GetSinglval(parstr));
    }

    [ExcelFunction("同类基金本月以来排名")]
    public static object RANK_FUND_SINC_MONTH0(
                [ExcelArgument("fnd_cde")] string fnd_cde,
                [ExcelArgument("class_code")] string class_code,
                [ExcelArgument("end_date")] string end_date
                )
    {
        string parstr = baseurl + @"/performance/fund_sinc_month0_rank/?" +
            @"fnd_cde=" + fnd_cde +
            @"&class_code=" + class_code +
            @"&end_date=" + end_date;
        return ExcelAsyncUtil.Run("RANK_FUND_SINC_MONTH0",
            new object[] { parstr },
            () => GetSinglval(parstr));
    }

    [ExcelFunction("周同类基金回报排名")]
    public static object RANK_FUND_WEEK(
                [ExcelArgument("fnd_cde")] string fnd_cde,
                [ExcelArgument("class_code")] string class_code,
                [ExcelArgument("end_date")] string end_date
                )
    {
        string parstr = baseurl + @"/performance/fund_week_rank/?" +
            @"fnd_cde=" + fnd_cde +
            @"&class_code=" + class_code +
            @"&end_date=" + end_date;
        return ExcelAsyncUtil.Run("RANK_FUND_WEEK",
            new object[] { parstr },
            () => GetSinglval(parstr));
    }

    [ExcelFunction("近1月同类基金回报排名")]
    public static object RANK_FUND_SINC_MONTH1(
                [ExcelArgument("fnd_cde")] string fnd_cde,
                [ExcelArgument("class_code")] string class_code,
                [ExcelArgument("end_date")] string end_date
                )
    {
        string parstr = baseurl + @"/performance/fund_sinc_month1_rank/?" +
            @"fnd_cde=" + fnd_cde +
            @"&class_code=" + class_code +
            @"&end_date=" + end_date;
        return ExcelAsyncUtil.Run("RANK_FUND_SINC_MONTH1",
            new object[] { parstr },
            () => GetSinglval(parstr));
    }


    [ExcelFunction("近3月同类基金回报排名")]
    public static object RANK_FUND_SINC_MONTH3(
                [ExcelArgument("fnd_cde")] string fnd_cde,
                [ExcelArgument("class_code")] string class_code,
                [ExcelArgument("end_date")] string end_date
                )
    {
        string parstr = baseurl + @"/performance/fund_sinc_month3_rank/?" +
            @"fnd_cde=" + fnd_cde +
            @"&class_code=" + class_code +
            @"&end_date=" + end_date;
        return ExcelAsyncUtil.Run("RANK_FUND_SINC_MONTH3",
            new object[] { parstr },
            () => GetSinglval(parstr));
    }



    [ExcelFunction("近一年同类基金回报率排名")]
    public static object RANK_FUND_SINC_YEAR1(
                [ExcelArgument("fnd_cde")] string fnd_cde,
                [ExcelArgument("class_code")] string class_code,
                [ExcelArgument("end_date")] string end_date
                )
    {
        string parstr = baseurl + @"/performance/fund_sinc_year1_rank/?" +
            @"fnd_cde=" + fnd_cde +
            @"&class_code=" + class_code +
            @"&end_date=" + end_date;
        return ExcelAsyncUtil.Run("RANK_FUND_SINC_YEAR1",
            new object[] { parstr },
            () => GetSinglval(parstr));
    }


    [ExcelFunction("近二年同类基金回报率排名")]
    public static object RANK_FUND_SINC_YEAR2(
                [ExcelArgument("fnd_cde")] string fnd_cde,
                [ExcelArgument("class_code")] string class_code,
                [ExcelArgument("end_date")] string end_date
                )
    {
        string parstr = baseurl + @"/performance/fund_sinc_year2_rank/?" +
            @"fnd_cde=" + fnd_cde +
            @"&class_code=" + class_code +
            @"&end_date=" + end_date;
        return ExcelAsyncUtil.Run("RANK_FUND_SINC_YEAR2",
            new object[] { parstr },
            () => GetSinglval(parstr));
    }


    [ExcelFunction("近三年同类基金回报率排名")]
    public static object RANK_FUND_SINC_YEAR3(
                [ExcelArgument("fnd_cde")] string fnd_cde,
                [ExcelArgument("class_code")] string class_code,
                [ExcelArgument("end_date")] string end_date
                )
    {
        string parstr = baseurl + @"/performance/fund_sinc_year3_rank/?" +
            @"fnd_cde=" + fnd_cde +
            @"&class_code=" + class_code +
            @"&end_date=" + end_date;
        return ExcelAsyncUtil.Run("RANK_FUND_SINC_YEAR3",
            new object[] { parstr },
            () => GetSinglval(parstr));
    }


    [ExcelFunction("今年以来同类基金回报率排名")]
    public static object RANK_FUND_SINC_YEAR0(
                [ExcelArgument("fnd_cde")] string fnd_cde,
                [ExcelArgument("class_code")] string class_code,
                [ExcelArgument("end_date")] string end_date
                )
    {
        string parstr = baseurl + @"/performance/fund_sinc_year0_rank/?" +
            @"fnd_cde=" + fnd_cde +
            @"&class_code=" + class_code +
            @"&end_date=" + end_date;
        return ExcelAsyncUtil.Run("RANK_FUND_SINC_YEAR0",
            new object[] { parstr },
            () => GetSinglval(parstr));
    }

    //  url(r'^return_sinc_year3', interval_return_view.return_sinc_year3, name='return_sinc_year3'),

    //  # 1、QDII基金区间收益率（同普通基金收益率）
    //
    //   # 2、HKEP（含交易费用）区间收益率
    //
    //   # 3、IEP（含交易费用）区间收益率
    //
    //   # 4、QDII基金区间平均资产净值
    [ExcelFunction("QDII基金区间平均资产净值")]
    public static object QDIINNETVALAVG(
                [ExcelArgument("fnd_cde")] string fnd_cde,
                [ExcelArgument("start_date")] string start_date,
                [ExcelArgument("end_date")] string end_date
                )
    {
        string parstr = baseurl + @"/qd/qd_interval_avg_nvl/?" +
            @"fnd_cde=" + fnd_cde +
            @"&start_date=" + start_date +
            @"&end_date=" + end_date;
        return ExcelAsyncUtil.Run("QDIINNETVALAVG",
            new object[] { parstr },
            () => GetSinglval(parstr));
    }
    //   # 5、HKEP区间平均配置比例
    //
    //
    //   # 6、IEP区间平均配置比例
    //
    //
    //   # 7、HKEP区间平均资产净值
    //   url(r'^hkep_interval_avg_nvl', qd_view.hkep_interval_avg_nvl, name='hkep_interval_avg_nvl'),

    [ExcelFunction("HKEP区间平均资产净值")]
    public static object QDHKEPNETVALAVG(
                [ExcelArgument("fnd_cde")] string fnd_cde,
                [ExcelArgument("start_date")] string start_date,
                [ExcelArgument("end_date")] string end_date
                )
    {
        string parstr = baseurl + @"/qd/qd_interval_avg_nvl/?" +
            @"fnd_cde=" + fnd_cde +
            @"&start_date=" + start_date +
            @"&end_date=" + end_date;
        return ExcelAsyncUtil.Run("QDHKEPNETVALAVG",
            new object[] { parstr },
            () => GetSinglval(parstr));
    }
    //
    //   # 8、IEP区间平均资产净值
    //   url(r'^iep_interval_avg_nvl', qd_view.iep_interval_avg_nvl, name='iep_interval_avg_nvl'),
    [ExcelFunction("IEP区间平均资产净值")]
    public static object QDIEPNETVALAVG(
                [ExcelArgument("fnd_cde")] string fnd_cde,
                [ExcelArgument("start_date")] string start_date,
                [ExcelArgument(Description = "First one!")] string end_date
                )
    {
        string parstr = baseurl + @"/qd/iep_interval_avg_nvl/?" +
            @"fnd_cde=" + fnd_cde +
            @"&start_date=" + start_date +
            @"&end_date=" + end_date;
        return ExcelAsyncUtil.Run("QDIEPNETVALAVG",
            new object[] { parstr },
            () => GetSinglval(parstr));
    }
    //
    //   # 9、HKEP区间收益贡献
    //
    //   # 10、IEP区间收益贡献
    //
    //   # 11、总费用区间收益贡献
    //
    //   # 12、HKEP持仓市值
    [ExcelFunction("HKEP持仓市值")]
    public static object QDHKEPHOLDMARKVAL(
                [ExcelArgument("fnd_cde")] string fnd_cde,
                [ExcelArgument("end_date")] string end_date
                )
    {
        string parstr = baseurl + @"/qd/hkep_loc_cur/?" +
            @"fnd_cde=" + fnd_cde +
            @"&end_date=" + end_date;
        return ExcelAsyncUtil.Run("QDHKEPHOLDMARKVAL",
            new object[] { parstr },
            () => GetSinglval(parstr));
    }
    //   # 13、IEP持仓市值
    //   url(r'^iep_loc_cur', qd_view.iep_loc_cur, name='iep_loc_cur'),
    //

    [ExcelFunction("IEP持仓市值")]
    public static object QDIEPHOLDMARKVAL(
                [ExcelArgument("fnd_cde")] string fnd_cde,
                [ExcelArgument("end_date")] string end_date
                )
    {
        string parstr = baseurl + @"/qd/iep_loc_cur/?" +
            @"fnd_cde=" + fnd_cde +
            @"&end_date=" + end_date;
        return ExcelAsyncUtil.Run("QDIEPHOLDMARKVAL",
            new object[] { parstr },
            () => GetSinglval(parstr));
    }
    //   # 14、QDII资产净值
    //   url(r'^qd_net_value', qd_view.qd_net_value, name='qd_net_value'),
    //

    [ExcelFunction("QDII资产净值")]
    public static object QDIINETVAL(
                [ExcelArgument("fnd_cde")] string fnd_cde,
                [ExcelArgument("end_date")] string end_date
                )
    {
        string parstr = baseurl + @"/qd/qd_net_value/?" +
            @"fnd_cde=" + fnd_cde +
            @"&end_date=" + end_date;
        return ExcelAsyncUtil.Run("QDIINETVAL",
            new object[] { parstr },
            () => GetSinglval(parstr));
    }
    //   # 15、IEP区间总买入金额（人民币）
    //   url(r'^iep_interval_buy_amt', qd_view.iep_interval_buy_amt, name='iep_interval_buy_amt'),
    //

    [ExcelFunction("IEP区间总买入金额（人民币）")]
    public static object QDIEPBUYAMT(
                   [ExcelArgument("fnd_cde")] string fnd_cde,
                   [ExcelArgument("start_date")] string start_date,
                   [ExcelArgument("end_date")] string end_date
                   )
    {
        string parstr = baseurl + @"/qd/iep_interval_buy_amt/?" +
            @"start_date=" + start_date +
            @"&fnd_cde=" + fnd_cde +
            @"&end_date=" + end_date;
        return ExcelAsyncUtil.Run("QDIEPBUYAMT",
            new object[] { parstr },
            () => GetSinglval(parstr));
    }
    //   # 16、IEP区间总卖出金额（人民币）
    [ExcelFunction("IEP区间总卖出金额（人民币）")]
    public static object QDIEPSELLAMT(
                [ExcelArgument("fnd_cde")] string fnd_cde,
                [ExcelArgument("start_date")] string start_date,
                [ExcelArgument("end_date")] string end_date
                )
    {
        string parstr = baseurl + @"/qd/iep_interval_sel_amt/?" +
            @"fnd_cde=" + fnd_cde +
            @"&start_date=" + start_date +
            @"&end_date=" + end_date;
        return ExcelAsyncUtil.Run("QDIEPSELLAMT",
            new object[] { parstr },
            () => GetSinglval(parstr));
    }
    //   # 17、HKEP区间总买入金额（人民币）
    [ExcelFunction("HKEP区间总买入金额（人民币）")]
    public static object QDHKEPBUYAMT(
                [ExcelArgument("fnd_cde")] string fnd_cde,
                [ExcelArgument("start_date")] string start_date,
                [ExcelArgument("end_date")] string end_date
                )
    {
        string parstr = baseurl + @"/qd/hkep_interval_buy_amt/?" +
            @"fnd_cde=" + fnd_cde +
            @"&start_date=" + start_date +
            @"&end_date=" + end_date;
        return ExcelAsyncUtil.Run("QDHKEPBUYAMT",
            new object[] { parstr },
            () => GetSinglval(parstr));
    }
    //   # 18、HKEP区间总卖出金额（人民币）
    //   url(r'^hkep_interval_sel_amt', qd_view.hkep_interval_sel_amt, name='hkep_interval_sel_amt'),
    //

    [ExcelFunction("HKEP区间总卖出金额（人民币）")]
    public static object QDHKEPSELLAMT(
                [ExcelArgument("fnd_cde")] string fnd_cde,
                [ExcelArgument("start_date")] string start_date,
                [ExcelArgument("end_date")] string end_date
                )
    {
        string parstr = baseurl + @"/qd/hkep_interval_sel_amt/?" +
            @"fnd_cde=" + fnd_cde +
            @"&start_date=" + start_date +
            @"&end_date=" + end_date;
        return ExcelAsyncUtil.Run("QDHKEPSELLAMT",
            new object[] { parstr },
            () => GetSinglval(parstr));
    }
    //   # 19、QDII基金管理费
    //   url(r'^qd_fnd_mgm_fee', qd_view.qd_fnd_mgm_fee, name='qd_fnd_mgm_fee'),
    [ExcelFunction("QDII基金管理费")]
    public static object QDIIMANAGFEE(
                [ExcelArgument("fnd_cde")] string fnd_cde,
                [ExcelArgument("month:yyyymm")] string month
                )
    {
        string parstr = baseurl + @"/qd/qd_fnd_mgm_fee/?" +
            @"fnd_cde=" + fnd_cde +
            @"&month=" + month;
        return ExcelAsyncUtil.Run("QDIIMANAGFEE",
            new object[] { parstr },
            () => GetSinglval(parstr));
    }
    //   # 20、QDII基金托管费
    //   url(r'^qd_fnd_tut_fee', qd_view.qd_fnd_tut_fee, name='qd_fnd_tut_fee'),
    //

    [ExcelFunction("QDII基金托管费")]
    public static object QDIITRUSTFEE(
                [ExcelArgument("fnd_cde")] string fnd_cde,
                [ExcelArgument("month:yyyymm")] string month
                )
    {
        string parstr = baseurl + @"/qd/qd_fnd_tut_fee/?" +
            @"fnd_cde=" + fnd_cde +
            @"&month=" + month;
        return ExcelAsyncUtil.Run("QDIITRUSTFEE",
            new object[] { parstr },
            () => GetSinglval(parstr));
    }
    //   # 21、QDII基金交易费
    //   url(r'^qd_fnd_txn_fee', qd_view.qd_fnd_txn_fee, name='qd_fnd_txn_fee'),
    //

    [ExcelFunction("QDII基金交易费")]
    public static object QDIITRADFEE(
                [ExcelArgument("fnd_cde")] string fnd_cde,
                [ExcelArgument("month:yyyymm")] string month
                )
    {
        string parstr = baseurl + @"/qd/qd_fnd_txn_fee/?" +
            @"fnd_cde=" + fnd_cde +
            @"&month=" + month;
        return ExcelAsyncUtil.Run("QDIITRADFEE",
            new object[] { parstr },
            () => GetSinglval(parstr));
    }
    //   #22、QDII基金其他费用
    //   url(r'^qd_fnd_ohr_fee', qd_view.qd_fnd_ohr_fee, name='qd_fnd_ohr_fee'),

    [ExcelFunction("QDII基金其他费用")]
    public static object QDIIOTHEFEE(
                [ExcelArgument("fnd_cde")] string fnd_cde,
                [ExcelArgument("month:yyyymm")] string month
                )
    {
        string parstr = baseurl + @"/qd/qd_fnd_ohr_fee/?" +
            @"fnd_cde=" + fnd_cde +
            @"&month=" + month;
        return ExcelAsyncUtil.Run("QDIIOTHEFEE",
            new object[] { parstr },
            () => GetSinglval(parstr));
    }

    //基金规模=====================================================================================================
    //   #公募基金规模

    [ExcelFunction("公募基金规模")]
    public static object FUNDSCALPUB(
                [ExcelArgument("fnd_cde")] string fnd_cde,
                [ExcelArgument("end_date")] string end_date
                )
    {
        string parstr = baseurl + @"/scale/public_fund_nvl/?" +
            @"fnd_cde=" + fnd_cde +
            @"&start_date=" + end_date +
            @"&end_date=" + end_date;
        return ExcelAsyncUtil.Run("FUNDSCALPUB",
            new object[] { parstr },
            () => GetSinglval(parstr));
    }

    //   #专户基金规模
    [ExcelFunction("专户基金规模")]
    public static object FUNDSCALSPC(
                [ExcelArgument("fnd_cde")] string fnd_cde,
                [ExcelArgument("end_date")] string end_date
                )
    {
        string parstr = baseurl + @"/scale/special_fund_nvl/?" +
            @"fnd_cde=" + fnd_cde +
            @"&start_date=" + end_date +
            @"&end_date=" + end_date;
        return ExcelAsyncUtil.Run("FUNDSCALSPC",
            new object[] { parstr },
            () => GetSinglval(parstr));
    }
    //获取单值公用方法
    public static object GetSinglval(
                  [ExcelArgument("Yahoo Ticker")] string url
                 )
    {

        string historicalData;
        var webConnection = new WebClient();
        webConnection.Headers.Add("Host", "dataplat.com");
        try
        {
            historicalData = webConnection.DownloadString(url);
        }
        catch (WebException ex)
        {
            throw new Exception("Unable to download the data! Check your Internet Connection!", ex);
        }
        finally
        {
            webConnection.Dispose();
        }
        Console.WriteLine(historicalData);
        JObject jO1 = JObject.Parse(historicalData);

        var a = jO1["data"]["val"]["0"];
        if (a is null)
        {
            return "";
        }
        return a.ToString();
    }

}